<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>yangchaojiang</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
    <meta name="keywords" content="yangjiang,yangjiang Blog" />
  
  <meta name="description" content="title: 基于exoPlayer 自定义播放器date: 2017-09-05 11:42:05tags:  Android Video ListVideo   基于exoPlayer 自定义播放器 Jplayer支持功能： 1 ExoUserPlayer  基本播放 2 GestureVideoPlayer   增加手势  亮度，音量，快进，等手势 3 ManualPlayer  默认手动">
<meta property="og:type" content="article">
<meta property="og:title" content="yangchaojiang">
<meta property="og:url" content="http://yangchaojiang.cn/2017/09/05/jPlayer-blog/index.html">
<meta property="og:site_name" content="yangchaojiang">
<meta property="og:description" content="title: 基于exoPlayer 自定义播放器date: 2017-09-05 11:42:05tags:  Android Video ListVideo   基于exoPlayer 自定义播放器 Jplayer支持功能： 1 ExoUserPlayer  基本播放 2 GestureVideoPlayer   增加手势  亮度，音量，快进，等手势 3 ManualPlayer  默认手动">
<meta property="og:image" content="http://yangchaojiang.cn/img/jplayer/sss.gif">
<meta property="og:image" content="http://yangchaojiang.cn/img/jplayer/20170905164501.png">
<meta property="og:updated_time" content="2018-03-09T14:55:22.717Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="yangchaojiang">
<meta name="twitter:description" content="title: 基于exoPlayer 自定义播放器date: 2017-09-05 11:42:05tags:  Android Video ListVideo   基于exoPlayer 自定义播放器 Jplayer支持功能： 1 ExoUserPlayer  基本播放 2 GestureVideoPlayer   增加手势  亮度，音量，快进，等手势 3 ManualPlayer  默认手动">
<meta name="twitter:image" content="http://yangchaojiang.cn/img/jplayer/sss.gif">
  
  
    <link rel="icon" href="/favicon.ico">
  
  <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css">
  <script src="/js/pace.min.js"></script>
  

  
  

</head>

<body>
  <div id="container">
      <header id="header">
    <div id="banner"></div>
    <div id="header-outer">
        <div id="header-menu" class="header-menu-pos animated">
            <div class="header-menu-container">
                <a href="/" class="left">
                    <span class="site-title">杨 江</span>
                </a>
                <nav id="header-menu-nav" class="right">
                    
                    <a target="_blank" href="//yanganan.cn">
                        <i class="fa fa-home"></i>
                        <span>Home</span>
                    </a>
                    
                    <a  href="/archives">
                        <i class="fa fa-archive"></i>
                        <span>Archives</span>
                    </a>
                    
                    <a target="_blank" href="http://www.yanganan.cn/server/about/aboutme.html">
                        <i class="fa fa-user"></i>
                        <span>About</span>
                    </a>
                    
                </nav>
                <a class="mobile-header-menu-button">
                    <i class="fa fa-bars"></i>
                </a>
            </div>
        </div>
        <div id="header-row">
            <div id="logo">
                <a href="/">
                    <img src="/images/logo.png" alt="logo">
                </a>
            </div>
            <div class="header-info">
                <div id="header-title">
                    
                    <h2>
                        杨 江
                    </h2>
                    
                </div>
                <div id="header-description">
                    
                    <h3>
                        海迷、爱运动、爱交友、爱旅行、喜欢接触新鲜事物、迎接新的挑战，更爱游离于错综复杂的编码与逻辑中
                    </h3>
                    
                </div>
            </div>
            <nav class="header-nav">
                <div class="social">
                    
                        <a title="Home" target="_blank" href="//yangchaojiang.cn">
                            <i class="fa fa-home fa-2x"></i></a>
                    
                        <a title="Github" target="_blank" href="//github.com/yangchaojiang">
                            <i class="fa fa-github fa-2x"></i></a>
                    
                        <a title="Weibo" target="_blank" href="//weibo.com/u/5114674051?topnav=1&wvr=6&topsug=1&is_all=1">
                            <i class="fa fa-weibo fa-2x"></i></a>
                    
                        <a title="Mail" target="_blank" href="mailto:yangchaojiang@outlook.com">
                            <i class="fa fa-envelope-o fa-2x"></i></a>
                    
                        <a title="qq" target="_blank" href="//wpa.qq.com/msgrd?v=3&uin=1007181167&site=qq&menu=yes">
                            <i class="fa fa-qq fa-2x"></i></a>
                    
                </div>
            </nav>
        </div>
    </div>
</header>
      <div class="outer">
        <section id="main" class="body-wrap"><article id="post-jPlayer-blog" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-inner">
    
    <div class="article-entry post-content" itemprop="articleBody">
      
            
            <hr>
<p>title: 基于exoPlayer 自定义播放器<br>date: 2017-09-05 11:42:05<br>tags:</p>
<ul>
<li>Android</li>
<li>Video</li>
<li>ListVideo</li>
</ul>
<hr>
<h3 id="基于exoPlayer-自定义播放器-Jplayer支持功能："><a href="#基于exoPlayer-自定义播放器-Jplayer支持功能：" class="headerlink" title="基于exoPlayer 自定义播放器 Jplayer支持功能："></a>基于exoPlayer 自定义播放器 Jplayer支持功能：</h3><ul>
<li>1 ExoUserPlayer  基本播放</li>
<li>2 GestureVideoPlayer   增加手势  亮度，音量，快进，等手势</li>
<li>3 ManualPlayer  默认手动播放，增加默认图</li>
<li>5 增加广告视频预览切换</li>
<li>6 增加视频清晰度切换</li>
<li>7 增加缓存视频功能</li>
<li>8 支持自定义各种数据源加载 Okttp,Rtmp, 缓存，Cronet等协议,</li>
<li>9 支持列表播放视频</li>
<li>10 支持多种文件类型，MP4，M4A，WebM，Matroska，Ogg，WAV，MP3，MPEG-TS，MPEG-PS，FLV，ADTS (AAC)，Flac，M3U8 等</li>
<li><p>11 支持网络类型 提示是否播放<br>&lt;!–more–&gt;</p>
<h4 id="预览-显示有点卡，帧数低，实际很流畅"><a href="#预览-显示有点卡，帧数低，实际很流畅" class="headerlink" title="预览 显示有点卡，帧数低，实际很流畅"></a>预览 显示有点卡，帧数低，实际很流畅</h4><p><img src="/img/jplayer/sss.gif" alt=""></p>
</li>
</ul>
<h3 id="一-引用类库"><a href="#一-引用类库" class="headerlink" title="一.引用类库"></a>一.引用类库</h3><pre><code>  &lt;span class=&quot;hljs-tag&quot;&gt;repositories&lt;/span&gt; {
         &lt;span class=&quot;hljs-tag&quot;&gt;jcenter&lt;/span&gt;()
         &lt;span class=&quot;hljs-tag&quot;&gt;maven&lt;/span&gt; { &lt;span class=&quot;hljs-attribute&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&quot;https://jitpack.io&quot;&lt;/span&gt; }
     }

 &lt;span class=&quot;hljs-tag&quot;&gt;dependencies&lt;/span&gt; {
    &lt;span class=&quot;hljs-attribute&quot;&gt;compile&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&apos;com.ycjiang:VideoPlayModule:1.4.8&apos;&lt;/span&gt;

 }
`&lt;/pre&gt;

### 二.控件属性

&gt; #### 1.控件属性引用
</code></pre><blockquote>
<pre><code>&lt;pre&gt;`  &lt;chuangyuan.ycj.videolibrary.widget.VideoPlayerView
        android:&lt;span class=&quot;hljs-variable&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;@+id/exo_play_context_id&quot;&lt;/span&gt;
        android:&lt;span class=&quot;hljs-variable&quot;&gt;layout_width=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        android:&lt;span class=&quot;hljs-variable&quot;&gt;layout_height=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
        android:&lt;span class=&quot;hljs-variable&quot;&gt;background=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;@android:color/transparent&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;resize_mode=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;fit&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;show_timeout=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;3000&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;controller_layout_id=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;@layout/simple_exo_playback_control_view&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;player_layout_id=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;@layout/simple_exo_view&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;surface_type=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;texture_view&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;use_artwork=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;true&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;paddingEnd=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;paddingStart=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;fastforward_increment=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;0&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;rewind_increment=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;0&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;user_watermark=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;@mipmap/watermark_big&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;player_list=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;true&quot;&lt;/span&gt;
        app:&lt;span class=&quot;hljs-variable&quot;&gt;use_controller=&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&quot;true&quot;&lt;/span&gt; &gt;&lt;/chuangyuan&gt;
`&lt;/pre&gt;

#### 2.属性说明
</code></pre><ol>
<li>player_layout_id  播放器布局， //必选&gt; <pre>`<span class="hljs-title">player_layout_id</span> 目前支持指定布局simple_exo_playback_control_view 后续版本，开放自定义使用这自定义<blockquote>
<pre><code>`&lt;/pre&gt;
</code></pre></blockquote>
</pre></li>
<li>controller_layout_id  控制器布局<code>//必选&gt; &lt;pre&gt;</code><span class="hljs-title">controller_layout_id</span>  支持自定义布局<blockquote>
<pre><code>`&lt;/pre&gt;
</code></pre></blockquote>
</li>
<li>surface_type 视频渲染类型 //texture_view 和surface_view //枚举类型。默认surface_view &gt; <pre><code>列表播放只能选择texture_view 不能选择surface_view，详情页面播放推荐surface_view</code></pre></li>
<li>use_controller   是否用户控制控制器  布尔类型</li>
<li>resize_mode  视频缩放渲染显示方式一共4种 //可选 美剧类型&gt; <pre>`    <span class="hljs-number">1</span><span class="hljs-class">.fit</span>          <span class="hljs-comment">//正常模式</span><blockquote>
<pre><code>    &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hljs-class&quot;&gt;.fixed_width&lt;/span&gt;  &lt;span class=&quot;hljs-comment&quot;&gt;//保持的是视频宽度，拉伸视频高度&lt;/span&gt;
    &lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hljs-class&quot;&gt;.fixed_height&lt;/span&gt; &lt;span class=&quot;hljs-comment&quot;&gt;//保持的是视频高度，拉伸视频宽度&lt;/span&gt;
    &lt;span class=&quot;hljs-number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hljs-class&quot;&gt;.fill&lt;/span&gt;          &lt;span class=&quot;hljs-comment&quot;&gt;//全屏模式，拉伸视频宽高&lt;/span&gt;
`&lt;/pre&gt;
</code></pre></blockquote>
</pre></li>
<li>default_artwork  占位图  //可选&gt; <pre>` 占位图 注意在控制布局后下面<blockquote>
<pre><code>`&lt;/pre&gt;
</code></pre></blockquote>
</pre></li>
<li>show_timeout  控制布局隐藏时间  默认值为3秒  //可选</li>
<li>paddingEnd，paddingStart 设置边距  默认值为0  //可选</li>
<li>fastforward_increment  设置快进增量,以毫秒为单位。 //可选</li>
<li>rewind_increment   设置快退增量,以毫秒为单位。  //可选</li>
<li>user_watermark    水印图片 默认在右上角  //可选</li>
<li><p>player_list      是否指定列表播放   //可选 默认 false  true 列表播放</p>
<h4 id="3-修改网络对话框提示文字内容"><a href="#3-修改网络对话框提示文字内容" class="headerlink" title="3.修改网络对话框提示文字内容"></a>3.修改网络对话框提示文字内容</h4></li>
</ol>
<blockquote>
<pre>` app.strings.xml
     <<span class="hljs-type">string</span> <span class="hljs-property">name</span>=<span class="hljs-string">"exo_play_reminder"</span>>您当前网络不是wifi，是否继续观看视频string>
     <<span class="hljs-type">string</span> <span class="hljs-property">name</span>=<span class="hljs-string">"exo_play_wifi_hint_no"</span>>提示string>
    `</pre>

</blockquote>
<pre><code>#### 4.在功能清单声明 AndroidManifest.xml

   在activity节点 加上“android:configChanges=&quot;orientation|keyboardHidden|screenSize&quot;”
    如下实例：
</code></pre><blockquote>
<pre>`      <activity android:<span="" class="hljs-variable">name=<span class="hljs-string">"chuangyuan.ycj.yjplay.MainListActivity"</span>
           android:<span class="hljs-variable">configChanges=</span><span class="hljs-string">"orientation|keyboardHidden|screenSize"</span>
           android:<span class="hljs-variable">screenOrientation=</span><span class="hljs-string">"portrait"</span>>
    `</activity></pre>

</blockquote>
</blockquote>
<pre><code>### 3.JAVA 代码

&gt; #### 1 播放控制类
</code></pre><blockquote>
<blockquote>
<p>1.ExoUserPlayer 基本播放父类，实现基本播放,设置setPlayUri();会自动加载播放<br>       2.GestureVideoPlayer  具有手势操作播放（调节亮度和视频进度，和音量）会自动加载播放<br>       2.ManualPlayer  点击开始按钮播放,具有手势功能，和列表播放</p>
</blockquote>
<pre><code>#### 2 播放

&lt;pre&gt;`&lt;span class=&quot;hljs-comment&quot;&gt;//实例化播放控制类&lt;/span&gt;
 ManualPlayer exoPlayerManager = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; ManualPlayer(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;,R.id.exo_play_context_id);
&lt;span class=&quot;hljs-comment&quot;&gt;//自定义你的数据源，后面详细介绍如何自定义数据源类&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;// ManualPlayer exoPlayerManager = new ManualPlayer(this,R.id.exo_play_context_id,new DataSource(this));&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;//加载m3u8&lt;/span&gt;
 exoPlayerManager.setPlayUri(&lt;span class=&quot;hljs-string&quot;&gt;&quot;http://dlhls.cdn.zhanqi.tv/zqlive/35180_KUDhx.m3u8&quot;&lt;/span&gt;);
 &lt;span class=&quot;hljs-comment&quot;&gt;//加载ts.文件&lt;/span&gt;
 exoPlayerManager.setPlayUri(&lt;span class=&quot;hljs-string&quot;&gt;&quot;http://185.73.239.15:25461/live/1/1/924.ts&quot;&lt;/span&gt;);
 &lt;span class=&quot;hljs-comment&quot;&gt;//播放本地视频&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;// exoPlayerManager.setPlayUri(&quot;/storage/emulated/0/DCIM/Camera/VID_20170717_011150.mp4&quot;);&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;//下面开启多线路播放&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;//  exoPlayerManager.setShowVideoSwitch(true); //开启切换按钮，默认关闭&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;//String [] test={&quot;http://120.25.246.21/vrMobile/travelVideo/zhejiang_xuanchuanpian.mp4&quot;,&quot;http://120.25.246.21/vrMobile/travelVideo/zhejiang_xuanchuanpian.mp4&quot;,&quot;http://120.25.246.21/vrMobile/travelVideo/zhejiang_xuanchuanpian.mp4&quot;};&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;// String[] name={&quot;超清&quot;,&quot;高清&quot;,&quot;标清&quot;};&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;//exoPlayerManager.setPlaySwitchUri(test,name);&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;//添加水印图片&lt;/span&gt;
 &lt;span class=&quot;hljs-comment&quot;&gt;// exoPlayerManager.setExoPlayWatermarkImg();&lt;/span&gt;
`&lt;/pre&gt;
</code></pre></blockquote>
<pre><code>   1.实例化播放控制类

&gt; &gt; &lt;pre&gt;`  ManualPlayer exoPlayerManager = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; ManualPlayer(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;,R.id.exo_play_context_id);
</code></pre><blockquote>
<blockquote>
<pre><code>  ManualPlayer exoPlayerManager = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; ManualPlayer(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;,videoPlayerView);
`&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<pre><code>   2.自定义你的数据源，后面详细介绍如何自定义数据源类

&gt; &gt; &lt;pre&gt;` ManualPlayer exoPlayerManager = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; ManualPlayer(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;,R.id.exo_play_context_id,&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; DataSource(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;));
</code></pre><blockquote>
<blockquote>
<pre><code> ManualPlayer exoPlayerManager = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; ManualPlayer(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;,videoPlayerView,&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; DataSource(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;));
`&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<pre><code>   3.设置视频标题

&gt; &gt; &lt;pre&gt;`  &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;setTitle&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;视频标题&quot;&lt;/span&gt;);
</code></pre><blockquote>
<blockquote>
<pre><code>`&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<pre><code>   4.添加水印图片

&gt; &gt; &lt;pre&gt;` &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;setExoPlayWatermarkImg&lt;/span&gt;(R.mipmap.watermark_big);     
</code></pre><blockquote>
<blockquote>
<pre><code>`&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<pre><code>   5.设置开始播放进度      

&gt; &gt; &lt;pre&gt;` exoPlayerManager.&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-title&quot;&gt;setPosition&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(&lt;span class=&quot;hljs-number&quot;&gt;1000&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;
</code></pre><blockquote>
<blockquote>
<pre><code>`&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<pre><code>   6.设置视频路径

&gt; &gt; &lt;pre&gt;` &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;setPlayUri&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;http://dlhls.cdn.zhanqi.tv/zqlive/35180_KUDhx.m3u8&quot;&lt;/span&gt;);
</code></pre><blockquote>
<blockquote>
<pre><code> &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;setPlayUri&lt;/span&gt;(Uri.&lt;span class=&quot;hljs-function&quot;&gt;parse&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;http://dlhls.cdn.zhanqi.tv/zqlive/35180_KUDhx.m3u8&quot;&lt;/span&gt;));
 &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;setPlayUri&lt;/span&gt;(Environment.&lt;span class=&quot;hljs-function&quot;&gt;getExternalStorageDirectory&lt;/span&gt;().&lt;span class=&quot;hljs-function&quot;&gt;getAbsolutePath&lt;/span&gt;()+&lt;span class=&quot;hljs-string&quot;&gt;&quot;/test.h264&quot;&lt;/span&gt;); &lt;span class=&quot;hljs-comment&quot;&gt;//本地视频&lt;/span&gt;
`&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<pre><code>   7.设置多线路播放

&gt; &gt; &lt;pre&gt;`  &lt;span class=&quot;hljs-comment&quot;&gt;//开启多线路设置，默认关闭 &lt;/span&gt;
</code></pre><blockquote>
<blockquote>
<pre><code>  exoPlayerManager.setShowVideoSwitch(&lt;span class=&quot;hljs-keyword&quot;&gt;true&lt;/span&gt;);
  &lt;span class=&quot;hljs-comment&quot;&gt;//支持List列表&lt;/span&gt;
  &lt;span class=&quot;hljs-built_in&quot;&gt;String&lt;/span&gt; [] test={&lt;span class=&quot;hljs-string&quot;&gt;&quot;http://120.25.246.21/vrMobile/travelVideo/zhejiang_xuanchuanpian.mp4&quot;&lt;/span&gt;,
  &lt;span class=&quot;hljs-string&quot;&gt;&quot;http://120.25.246.21/vrMobile/travelVideo/zhejiang_xuanchuanpian.mp4&quot;&lt;/span&gt;,
   http:&lt;span class=&quot;hljs-comment&quot;&gt;//120.25.246.21/vrMobile/travelVideo/zhejiang_xuanchuanpian.mp4&quot;};&lt;/span&gt;
   &lt;span class=&quot;hljs-built_in&quot;&gt;String&lt;/span&gt;[] name={&lt;span class=&quot;hljs-string&quot;&gt;&quot;超清&quot;&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;高清&quot;&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;标清&quot;&lt;/span&gt;};
   exoPlayerManager.setPlaySwitchUri(test,name);
`&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<pre><code>   8.设置监听回调VideoInfoListener

&gt; &gt; &lt;pre&gt;` &lt;span class=&quot;hljs-tag&quot;&gt;exoPlayerManager&lt;/span&gt;&lt;span class=&quot;hljs-class&quot;&gt;.setVideoInfoListener&lt;/span&gt;(new &lt;span class=&quot;hljs-function&quot;&gt;VideoInfoListener&lt;/span&gt;() {
</code></pre><blockquote>
<blockquote>
<pre><code>               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
               public void &lt;span class=&quot;hljs-function&quot;&gt;onPlayStart&lt;/span&gt;() {
                     &lt;span class=&quot;hljs-comment&quot;&gt;//开始播放&lt;/span&gt;
               }

               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
               public void &lt;span class=&quot;hljs-function&quot;&gt;onLoadingChanged&lt;/span&gt;() {
                         &lt;span class=&quot;hljs-comment&quot;&gt;//加载变化&lt;/span&gt;
               }

               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
               public void &lt;span class=&quot;hljs-function&quot;&gt;onPlayerError&lt;/span&gt;(ExoPlaybackException e) {
                         &lt;span class=&quot;hljs-comment&quot;&gt;//加载错误&lt;/span&gt;
              }

               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
               public void &lt;span class=&quot;hljs-function&quot;&gt;onPlayEnd&lt;/span&gt;() {
                      &lt;span class=&quot;hljs-comment&quot;&gt;//播放结束&lt;/span&gt;
               }

               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
               public void &lt;span class=&quot;hljs-function&quot;&gt;onBack&lt;/span&gt;() {
                   &lt;span class=&quot;hljs-comment&quot;&gt;//返回回调&lt;/span&gt;
                   &lt;span class=&quot;hljs-attribute&quot;&gt;Toast&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;makeText&lt;/span&gt;(MainDetailedActivity.this,&lt;span class=&quot;hljs-string&quot;&gt;&quot;f返回&quot;&lt;/span&gt;,Toast.LENGTH_LONG).&lt;span class=&quot;hljs-function&quot;&gt;show&lt;/span&gt;();
                   &lt;span class=&quot;hljs-attribute&quot;&gt;finish&lt;/span&gt;();

               }
               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
               public void &lt;span class=&quot;hljs-function&quot;&gt;onRepeatModeChanged&lt;/span&gt;(int repeatMode) {
                   &lt;span class=&quot;hljs-comment&quot;&gt;//模式变化&lt;/span&gt;
               }
           });  
`&lt;/pre&gt;

   9.覆写Activity和Fragment周期方法 

&lt;pre&gt;`        &lt;span class=&quot;hljs-tag&quot;&gt;Override&lt;/span&gt;
        &lt;span class=&quot;hljs-tag&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-tag&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-tag&quot;&gt;onResume&lt;/span&gt;() {
            &lt;span class=&quot;hljs-attribute&quot;&gt;super&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onResume&lt;/span&gt;();
            &lt;span class=&quot;hljs-attribute&quot;&gt;Log&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;d&lt;/span&gt;(TAG, &lt;span class=&quot;hljs-string&quot;&gt;&quot;onResume&quot;&lt;/span&gt;);
            &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onResume&lt;/span&gt;();
        }

        &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
        public void &lt;span class=&quot;hljs-function&quot;&gt;onPause&lt;/span&gt;() {
            &lt;span class=&quot;hljs-attribute&quot;&gt;super&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onPause&lt;/span&gt;();
            &lt;span class=&quot;hljs-attribute&quot;&gt;Log&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;d&lt;/span&gt;(TAG, &lt;span class=&quot;hljs-string&quot;&gt;&quot;onPause&quot;&lt;/span&gt;);
            &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onPause&lt;/span&gt;();
        }

        &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
        protected void &lt;span class=&quot;hljs-function&quot;&gt;onDestroy&lt;/span&gt;() {
            &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onDestroy&lt;/span&gt;();
            &lt;span class=&quot;hljs-attribute&quot;&gt;super&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onDestroy&lt;/span&gt;();

        }

        &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
        public void &lt;span class=&quot;hljs-function&quot;&gt;onConfigurationChanged&lt;/span&gt;(Configuration newConfig) {
            &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onConfigurationChanged&lt;/span&gt;(newConfig);&lt;span class=&quot;hljs-comment&quot;&gt;//横竖屏切换&lt;/span&gt;
            &lt;span class=&quot;hljs-attribute&quot;&gt;super&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onConfigurationChanged&lt;/span&gt;(newConfig);
        }

        &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
        public void &lt;span class=&quot;hljs-function&quot;&gt;onBackPressed&lt;/span&gt;() {&lt;span class=&quot;hljs-comment&quot;&gt;//使用播放返回键监听&lt;/span&gt;
           &lt;span class=&quot;hljs-attribute&quot;&gt;exoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onBackPressed&lt;/span&gt;();
        }
`&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<pre><code>### 三.列表

   1.列表播放，只能使用ManualPlayer,在你的VideoHolder
</code></pre><ul>
<li>1在列表控件使用属性 ”app:controller_layout_id=”@layout/simple_exo_playback＿list_view”“  //提供默列表控制布局</li>
<li>2.player_list=”true” 设置为true 开启列表模式</li>
<li><p>3.demo:&gt; &gt; <pre>`     <span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">VideoAdapter</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">RecyclerView</span>.<span class="hljs-title">Adapter</span>&lt;<span class="hljs-title">VideoAdapter</span>.<span class="hljs-title">VideoViewHolder</span>&gt; </span>{</pre></p>
<blockquote>
<blockquote>
<pre><code>       &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; Context mContext;
      &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; List&lt;String&gt; mVideoList;
      &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;VideoAdapter&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(Context context, List&lt;String&gt; videoList)&lt;/span&gt; &lt;/span&gt;{
          mContext = context;
          mVideoList = videoList;
      }
      &lt;span class=&quot;hljs-annotation&quot;&gt;@Override&lt;/span&gt;
      &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;getItemCount&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;()&lt;/span&gt; &lt;/span&gt;{
          &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; mVideoList.size();
      }
      &lt;span class=&quot;hljs-annotation&quot;&gt;@Override&lt;/span&gt;
      &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; VideoViewHolder &lt;span class=&quot;hljs-title&quot;&gt;onCreateViewHolder&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(ViewGroup parent, &lt;span class=&quot;hljs-keyword&quot;&gt;int&lt;/span&gt; viewType)&lt;/span&gt; &lt;/span&gt;{
          View itemView = LayoutInflater.from(mContext).inflate(R.layout.item_video1, parent, &lt;span class=&quot;hljs-keyword&quot;&gt;false&lt;/span&gt;);
          &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;VideoViewHolder&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(itemView)&lt;/span&gt;&lt;/span&gt;;
      }
      &lt;span class=&quot;hljs-annotation&quot;&gt;@Override&lt;/span&gt;
      &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;onBindViewHolder&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(VideoViewHolder holder, &lt;span class=&quot;hljs-keyword&quot;&gt;int&lt;/span&gt; position)&lt;/span&gt; &lt;/span&gt;{
          String video = mVideoList.get(position);
          holder.bindData(video);
      }
      &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-class&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;VideoViewHolder&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;RecyclerView&lt;/span&gt;.&lt;span class=&quot;hljs-title&quot;&gt;ViewHolder&lt;/span&gt; &lt;/span&gt;{
          ManualPlayer userPlayer;
          VideoPlayerView playerView;
          &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;VideoViewHolder&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(View itemView)&lt;/span&gt; &lt;/span&gt;{
              &lt;span class=&quot;hljs-keyword&quot;&gt;super&lt;/span&gt;(itemView);
              &lt;span class=&quot;hljs-comment&quot;&gt;//初始化控件&lt;/span&gt;
              playerView = (VideoPlayerView) itemView.findViewById(R.id.item_exo_player_view);
              userPlayer = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; ManualPlayer((Activity) mContext, playerView);
          }
         &lt;span class=&quot;hljs-javadoc&quot;&gt;/**
         *绑定数据源
         ***/&lt;/span&gt;
          &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;bindData&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(String videoBean)&lt;/span&gt; &lt;/span&gt;{
              userPlayer.setTitle(&lt;span class=&quot;hljs-string&quot;&gt;&quot;&quot;&lt;/span&gt; + getAdapterPosition());
              userPlayer.setPlayUri(videoBean);
              Glide.with(mContext)
              .load(&lt;span class=&quot;hljs-string&quot;&gt;&quot;http://i3.letvimg.com/lc08_yunzhuanma/201707/29/20/49/3280a525bef381311b374579f360e80a_v2_MTMxODYyNjMw/thumb/2_960_540.jpg&quot;&lt;/span&gt;)
              .into(playerView.getPreviewImage());
          }
      }
`&lt;/pre&gt;
2.列表播放周期方法 列表在Activity或者Fragment  实现相应周期方法
&lt;pre&gt;`               &lt;span class=&quot;hljs-tag&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;hljs-tag&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;hljs-tag&quot;&gt;onPause&lt;/span&gt;() {
                   &lt;span class=&quot;hljs-attribute&quot;&gt;super&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onPause&lt;/span&gt;();
                   &lt;span class=&quot;hljs-attribute&quot;&gt;VideoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;getInstance&lt;/span&gt;().&lt;span class=&quot;hljs-function&quot;&gt;onPause&lt;/span&gt;();
               }
               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
                protected void &lt;span class=&quot;hljs-function&quot;&gt;onResume&lt;/span&gt;() {
                   &lt;span class=&quot;hljs-attribute&quot;&gt;super&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onResume&lt;/span&gt;();
                   &lt;span class=&quot;hljs-attribute&quot;&gt;VideoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;getInstance&lt;/span&gt;().&lt;span class=&quot;hljs-function&quot;&gt;onResume&lt;/span&gt;();
               }
               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
               protected void &lt;span class=&quot;hljs-function&quot;&gt;onDestroy&lt;/span&gt;() {
                   &lt;span class=&quot;hljs-attribute&quot;&gt;super&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;onDestroy&lt;/span&gt;();
                   &lt;span class=&quot;hljs-attribute&quot;&gt;VideoPlayerManager&lt;/span&gt;.&lt;span class=&quot;hljs-function&quot;&gt;getInstance&lt;/span&gt;().&lt;span class=&quot;hljs-function&quot;&gt;onDestroy&lt;/span&gt;();
               }
               &lt;span class=&quot;hljs-variable&quot;&gt;@Override&lt;/span&gt;
               public void &lt;span class=&quot;hljs-function&quot;&gt;onBackPressed&lt;/span&gt;() {
                   &lt;span class=&quot;hljs-comment&quot;&gt;//返回监听类&lt;/span&gt;
                   &lt;span class=&quot;hljs-tag&quot;&gt;if&lt;/span&gt; (!VideoPlayerManager.&lt;span class=&quot;hljs-function&quot;&gt;getInstance&lt;/span&gt;()&lt;span class=&quot;hljs-class&quot;&gt;.onBackPressed&lt;/span&gt;()){
                       &lt;span class=&quot;hljs-attribute&quot;&gt;finish&lt;/span&gt;();
                   }
               }    `&lt;/pre&gt;
</code></pre></blockquote>
</blockquote>
<h3 id="四-数据源工厂类"><a href="#四-数据源工厂类" class="headerlink" title="四.数据源工厂类"></a>四.数据源工厂类</h3><h4 id="1-默认数据源"><a href="#1-默认数据源" class="headerlink" title="1.默认数据源"></a>1.默认数据源</h4><blockquote>
<blockquote>
<pre>`    缓存 : CacheDataSinkFactory,CacheDataSourceFactory
        <span class="hljs-string">http :</span> DefaultDataSourceFactory,DefaultHttpDataSourceFactory
        <span class="hljs-string">Priority :</span> PriorityDataSourceFactory      
    `</pre>

<pre><code>#### 2 自定义数据源引用

&lt;pre&gt;`&lt;span class=&quot;hljs-keyword&quot;&gt;compile&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&apos;com.google.android.exoplayer:extension-okhttp:r2.5.1&apos;&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;compile&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&apos;com.google.android.exoplayer:extension-rtmp:r2.5.1&apos;&lt;/span&gt;
`&lt;/pre&gt;

#### 3.自定义数据源工厂类:
</code></pre><ul>
<li>实现接口 DataSourceListener  然后在getDataSourceFactory方法里 自定义 数据源</li>
<li>在你使用播放控件时中实例化类<br>  exoPlayerManager = new GestureVideoPlayer(this,videoPlayerView,new DataSource(this));<br>  exoPlayerManager = new GestureVideoPlayer(this,(R.id.exo_play_context_id,new DataSource(this));</li>
</ul>
</blockquote>
</blockquote>
</li>
<li><p>demo代码:</p>
<blockquote>
<blockquote>
<p><pre>`<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DataSource</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">DataSourceListener</span> </span>{</pre></p>
<pre><code>      &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;final&lt;/span&gt; String TAG = &lt;span class=&quot;hljs-string&quot;&gt;&quot;DataSource&quot;&lt;/span&gt;;
      &lt;span class=&quot;hljs-keyword&quot;&gt;private&lt;/span&gt; Context context;
       &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt;   &lt;span class=&quot;hljs-title&quot;&gt;DataSource&lt;/span&gt; &lt;span class=&quot;hljs-params&quot;&gt;(Context context)&lt;/span&gt;&lt;/span&gt;{
           &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.context=context;
       }
      &lt;span class=&quot;hljs-annotation&quot;&gt;@Override&lt;/span&gt;
      &lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;/span&gt; com.google.android.exoplayer2.upstream.DataSource.&lt;span class=&quot;hljs-function&quot;&gt;Factory &lt;span class=&quot;hljs-title&quot;&gt;getDataSourceFactory&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;()&lt;/span&gt; &lt;/span&gt;{
           OkHttpClient  okHttpClient = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; OkHttpClient();
           OkHttpDataSourceFactory OkHttpDataSourceFactory=    &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; OkHttpDataSourceFactory(okHttpClient, Util.getUserAgent(context, context.getApplicationContext().getPackageName()),&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; DefaultBandwidthMeter() );
              &lt;span class=&quot;hljs-comment&quot;&gt;//使用OkHttpClient 数据源工厂&lt;/span&gt;
            &lt;span class=&quot;hljs-comment&quot;&gt;//return  OkHttpDataSourceFactory; ;&lt;/span&gt;
            &lt;span class=&quot;hljs-comment&quot;&gt;//默认数据源工厂&lt;/span&gt;
            &lt;span class=&quot;hljs-comment&quot;&gt;// return new JDefaultDataSourceFactory(context);&lt;/span&gt;
            &lt;span class=&quot;hljs-comment&quot;&gt;// Rtmp数据源工厂 对 Rtmp 协议支持&lt;/span&gt;
            &lt;span class=&quot;hljs-comment&quot;&gt;// return  new RtmpDataSourceFactory();&lt;/span&gt;
           &lt;span class=&quot;hljs-comment&quot;&gt;//缓存使用和组合使用&lt;/span&gt;
            LeastRecentlyUsedCacheEvictor evictor = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; LeastRecentlyUsedCacheEvictor(&lt;span class=&quot;hljs-number&quot;&gt;1000000000&lt;/span&gt;);
           SimpleCache   simpleCache = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; SimpleCache(&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; File(context.getCacheDir(), &lt;span class=&quot;hljs-string&quot;&gt;&quot;media&quot;&lt;/span&gt;), evictor);
           &lt;span class=&quot;hljs-comment&quot;&gt;//缓存数据源使用，内部使用DefaultDataSourceFactory数据源工厂类&lt;/span&gt;
           &lt;span class=&quot;hljs-comment&quot;&gt;// return  new CacheDataSinkFactory(simpleCache,10000);&lt;/span&gt;
           &lt;span class=&quot;hljs-comment&quot;&gt;// 配合okHttp数据源工厂类&lt;/span&gt;
           &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt;  &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;CacheDataSourceFactory&lt;/span&gt;&lt;span class=&quot;hljs-params&quot;&gt;(simpleCache, OkHttpDataSourceFactory)&lt;/span&gt;&lt;/span&gt;;
           &lt;span class=&quot;hljs-comment&quot;&gt;//使用配合默认数据源红工厂类&lt;/span&gt;
           &lt;span class=&quot;hljs-comment&quot;&gt;// return  new CacheDataSourceFactory(simpleCache, new JDefaultDataSourceFactory(context));&lt;/span&gt;
           &lt;span class=&quot;hljs-comment&quot;&gt;//使用提供缓存数据源工厂类&lt;/span&gt;
           &lt;span class=&quot;hljs-comment&quot;&gt;// return new CacheDataSourceFactory(context,1000,1000);&lt;/span&gt;
          }
`&lt;/pre&gt;
   }
</code></pre></blockquote>
</blockquote>
<h3 id="五-自定义控制布局"><a href="#五-自定义控制布局" class="headerlink" title="五.自定义控制布局"></a>五.自定义控制布局</h3></li>
<li><p>1.使用自定义控制布局  app:controller_layout_id=”@layout/simple_exo_playback_control_view” 详细看 demo&gt; &gt; <pre>`<span class="hljs-label">app:</span>controller_layout_id  指向您的布局名称</pre></p>
<blockquote>
<blockquote>
<p>  <img src="/img/jplayer/20170905164501.png" alt=""></p>
<pre><code>*   **_2.注意自定义控制布局事项 不能改变控件类型，可以改变控件的样式，位置，属性等_**
</code></pre></blockquote>
</blockquote>
</li>
</ul>
<h3 id="项目地址－戳我"><a href="#项目地址－戳我" class="headerlink" title="项目地址－戳我"></a><a href="https://github.com/yangchaojiang/yjPlay" target="_blank" rel="external">项目地址－戳我</a></h3>
            <div class="post-copyright">
    <div class="content">
        <p>最后更新： 2018年03月09日 22:55</p>
        <p>原始链接： <a class="post-url" href="/2017/09/05/jPlayer-blog/" title="">http://yangchaojiang.cn/2017/09/05/jPlayer-blog/</a></p>
        <footer>
            <a href="http://yangchaojiang.cn">
                <img src="/images/logo.png" alt="杨朝江">
                杨朝江
            </a>
        </footer>
    </div>
</div>

      
    </div>
    <footer class="article-footer">
        
        
<div class="post-share">
    <a href="javascript:;" id="share-sub" class="post-share-fab">
        <i class="fa fa-share-alt"></i>
    </a>
    <div class="post-share-list" id="share-list">
        <ul class="share-icons">
          <li>
            <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yangchaojiang.cn/2017/09/05/jPlayer-blog/&title=yangchaojiang&pic=http://yangchaojiang.cnimages/logo.png" data-title="微博">
              <i class="fa fa-weibo"></i>
            </a>
          </li>
          <li>
            <a class="weixin share-sns" id="wxFab" href="javascript:;" data-title="微信">
              <i class="fa fa-weixin"></i>
            </a>
          </li>
          <li>
            <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yangchaojiang.cn/2017/09/05/jPlayer-blog/&title=yangchaojiang&source=" data-title="QQ">
              <i class="fa fa-qq"></i>
            </a>
          </li>
          <li>
            <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yangchaojiang.cn/2017/09/05/jPlayer-blog/" data-title="Facebook">
              <i class="fa fa-facebook"></i>
            </a>
          </li>
          <li>
            <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=yangchaojiang&url=http://yangchaojiang.cn/2017/09/05/jPlayer-blog/&via=http://yangchaojiang.cn" data-title="Twitter">
              <i class="fa fa-twitter"></i>
            </a>
          </li>
          <li>
            <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yangchaojiang.cn/2017/09/05/jPlayer-blog/" data-title="Google+">
              <i class="fa fa-google-plus"></i>
            </a>
          </li>
        </ul>
     </div>
</div>
<div class="post-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;" id="wxShare-close">×</a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=http://yangchaojiang.cn/2017/09/05/jPlayer-blog/" alt="微信分享二维码">
</div>

<div class="mask"></div>

        
        <ul class="article-footer-menu">
            
            
        </ul>
        
    </footer>
  </div>
</article>


    <aside class="post-toc-pos post-toc-top" id="post-toc">
        <nav class="post-toc-wrap">
            <ol class="post-toc"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#基于exoPlayer-自定义播放器-Jplayer支持功能："><span class="post-toc-text">基于exoPlayer 自定义播放器 Jplayer支持功能：</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#预览-显示有点卡，帧数低，实际很流畅"><span class="post-toc-text">预览 显示有点卡，帧数低，实际很流畅</span></a></li></ol></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#一-引用类库"><span class="post-toc-text">一.引用类库</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#3-修改网络对话框提示文字内容"><span class="post-toc-text">3.修改网络对话框提示文字内容</span></a></li></ol></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#四-数据源工厂类"><span class="post-toc-text">四.数据源工厂类</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-4"><a class="post-toc-link" href="#1-默认数据源"><span class="post-toc-text">1.默认数据源</span></a></li></ol></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#五-自定义控制布局"><span class="post-toc-text">五.自定义控制布局</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#项目地址－戳我"><span class="post-toc-text">项目地址－戳我</span></a></li></ol>
        </nav>
    </aside>
    

<nav id="article-nav">
  
    <a href="/2018/03/06/lambda-blog/" id="article-nav-newer" class="article-nav-link-wrap">

      <span class="article-nav-title">
        <i class="fa fa-hand-o-left" aria-hidden="true"></i>
        
          Lambda 表达式有何用处？如何使用？（非原创）
        
      </span>
    </a>
  
  
    <a href="/2017/08/27/share-wenzhang/" id="article-nav-older" class="article-nav-link-wrap">
      <span class="article-nav-title">100篇精选干货</span>
      <i class="fa fa-hand-o-right" aria-hidden="true"></i>
    </a>
  
</nav>



    
        <div id="SOHUCS" sid="jPlayer-blog" ></div>
<script type="text/javascript">
    (function(){
        var appid = 'cyt36tWXs';
        var conf = '42b79e0329709ef48318d7d6739122c2';
        var width = window.innerWidth || document.documentElement.clientWidth;
        if (width < 960) {
            window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); } })(); </script>
    
</section>
        
      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info" class="inner">
      
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


      <p>
        Powered by  <a href="http://hexo.io/" target="_blank">Hexo</a>
        Theme <a href="//github.com/wongminho/hexo-theme-miho" target="_blank">MiHo</a>
      &copy; 2018 杨朝江<br>
      </p>
    </div>
  </div>
</footer>
    <script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
  var mihoConfig = {
      root: "http://yangchaojiang.cn",
      animate: true,
      isHome: false,
      share: true
  }
</script>
<div class="sidebar">
    <div id="sidebar-search" title="Search">
        <i class="fa fa-search"></i>
    </div>
    <div id="sidebar-category" title="Categories">
        <i class="fa fa-book"></i>
    </div>
    <div id="sidebar-tag" title="Tags">
        <i class="fa fa-tags"></i>
    </div>
    <div id="sidebar-top">
        <span class="sidebar-top-icon"><i class="fa fa-angle-up"></i></span>
    </div>
</div>
<div class="sidebar-menu-box" id="sidebar-menu-box">
    <div class="sidebar-menu-box-container">
        <div id="sidebar-menu-box-categories">
            
        </div>
        <div id="sidebar-menu-box-tags">
            <a href="/tags/Android-Kotlin/" style="font-size: 10px;">-Android -Kotlin</a> <a href="/tags/Android/" style="font-size: 20px;">Android</a> <a href="/tags/Architecture-Components/" style="font-size: 10px;">Architecture Components</a> <a href="/tags/Architecture-Components/" style="font-size: 13.33px;">Architecture_Components</a> <a href="/tags/Gradle/" style="font-size: 10px;">Gradle</a> <a href="/tags/Kotlin/" style="font-size: 16.67px;">Kotlin</a> <a href="/tags/LiveData/" style="font-size: 10px;">LiveData</a> <a href="/tags/Room/" style="font-size: 10px;">Room</a> <a href="/tags/java/" style="font-size: 13.33px;">java</a> <a href="/tags/kotlin/" style="font-size: 10px;">kotlin</a> <a href="/tags/lambda/" style="font-size: 10px;">lambda</a> <a href="/tags/leficycle/" style="font-size: 10px;">leficycle</a>
        </div>
    </div>
    <a href="javascript:;" class="sidebar-menu-box-close">&times;</a>
</div>
<div class="mobile-header-menu-nav" id="mobile-header-menu-nav">
    <div id="mobile-header-menu-container">
        <span class="title">Menu</span>
        <ul class="mobile-header-menu-navbar">
            
            <li>
                <a target="_blank" href="//yanganan.cn">
                    <i class="fa fa-home"></i><span>Home</span>
                </a>
            </li>
            
            <li>
                <a  href="/archives">
                    <i class="fa fa-archive"></i><span>Archives</span>
                </a>
            </li>
            
            <li>
                <a target="_blank" href="http://www.yanganan.cn/server/about/aboutme.html">
                    <i class="fa fa-user"></i><span>About</span>
                </a>
            </li>
            
        </ul>
    </div>
</div>
<div class="search-wrap">
    <span class="search-close">&times;</span>
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
            <i class="icon icon-lg icon-chevron-left"></i>
        </a>
        <input class="search-field" placeholder="Search..." id="keywords">
        <a id="search-submit" href="javascript:;">
            <i class="fa fa-search"></i>
        </a>
    <div class="search-container" id="search-container">
        <ul class="search-result" id="search-result">
        </ul>
    </div>
</div>

<div id="search-tpl">
    <li class="search-result-item">
        <a href="{url}" class="search-item-li">
            <span class="search-item-li-title" title="{title}">{title}</span>
        </a>
    </li>
</div>
<script src="/js/search.js"></script>
<script src="/js/main.js"></script>


  <script src="//cdn.bootcss.com/particles.js/2.0.0/particles.min.js"></script>
  <div id="particles"></div>
  <script src="/js/particles.js"></script>







  <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  <script src="//cdn.bootcss.com/scrollReveal.js/3.0.5/scrollreveal.js"></script>
  <script src="/js/animate.js"></script>

  </div>
</body>
</html>